<div class="admin_left actions">
	<h3><?php echo __('Actions'); ?></h3>
	<ul>

		<li style="list-style-type:none; margin-bottom:20%;"><?php echo $this->Html->link(__('List Consignments'), array('action' => 'index'),array('class' => 'consistentButton2')); ?></li>
		<li style="list-style-type:none; margin-bottom:20%;"><?php echo $this->Html->link(__('List Items'), array('controller' => 'items', 'action' => 'index'),array('class' => 'consistentButton2')); ?> </li>
		<li style="list-style-type:none; margin-bottom:20%;"><?php echo $this->Html->link(__('New Item'), array('controller' => 'items', 'action' => 'add'),array('class' => 'consistentButton2')); ?> </li>
		<li style="list-style-type:none; margin-bottom:20%;"><?php echo $this->Html->link(__('List Consigners'), array('controller' => 'consigners', 'action' => 'index'),array('class' => 'consistentButton2')); ?> </li>
		<li style="list-style-type:none; margin-bottom:20%;"><?php echo $this->Html->link(__('New Consigner'), array('controller' => 'consigners', 'action' => 'add'),array('class' => 'consistentButton2')); ?> </li>
	</ul>
</div>

<div class="admin_right consignments form">

        <div id=breadcrumbAdmin>
            <?php $this->Html->addCrumb('Consignments', '/Consignments/index'); ?>
            <?php $this->Html->addCrumb('Add', '/Consignments/add', array('style'=> ('text-decoration:underline; color:#EB1E70;'))); ?>
            <?php echo $this->Html->getCrumbs(' > ', array( 'text' => 'Transactions', 'url' => array('controller' => 'sales', 'action' => 'index'), 'escape' => false)); ?>
        </div>

<?php echo $this->Form->create('Consignment'); ?>
	<fieldset>
		<legend><?php echo __('Add Consignment'); ?></legend>

	<?php
		echo $this->Form->input('item_id');
		echo $this->Form->button('New Item', array('type'=> 'button', 'class' => 'item-popup-window'));
		echo $this->Form->input('consigner_id');
		echo $this->Form->button('New Consigner', array('type'=> 'button', 'class' => 'consigner-popup-window'));
		echo $this->Form->input('note');
	?>
	</fieldset>
<?php echo $this->Form->end(__('Submit')); ?>
</div>


<!- function -->

<script type="text/javascript">

    $(document).ready(function() {

        $('.item-popup-window').click(function(){

           var popupBoxItem = '#popup-box-item';

           $(popupBoxItem).fadeIn(400);

           var popMargTop = ($(popupBoxItem).height() + 24) /2;
           var popMargLeft = ($(popupBoxItem).height() + 24) /2;

           $(popupBoxItem).css({
            'margin-top' : -popMargTop,
            'margin-left' : -popMargLeft
           });

           $('body').append('<div id="mask"></div>');
           $('#mask').fadeIn(400);
           return false;

        });



        $('.consigner-popup-window').click(function(){

           var popupBoxConsigner = '#popup-box-consigner';

           $(popupBoxConsigner).fadeIn(400);

           var popMargTop = ($(popupBoxConsigner).height() + 24) /2;
           var popMargLeft = ($(popupBoxConsigner).height() + 24) /2;

           $(popupBoxConsigner).css({
            'margin-top' : -popMargTop,
            'margin-left' : -popMargLeft
           });

           $('body').append('<div id="mask"></div>');
           $('#mask').fadeIn(400);
           return false;

        });


        $('button.close, #mask').bind('click', function(){
            $('#mask, .popupInfoItem').fadeOut(400, function(){
                $('#mask').remove();
            });
            return false;

        });




    });

$(document).keyup(function(e) {
    if ( e.keyCode == 27) {
        $('#mask, .popupInfoItem, .popupInfo, #popup-box-item, #popup-box-consigner').fadeOut(400);
        return false;
    }
});


</script>
<!-- end  function -->









<!-- popup button for item begins -->

<?php echo $this->Html->script('jquery.form'); ?>
<div id="popup-box-item" class="popupInfoItem">

     <div id="infoleft">

        <?php echo $this->Form->create('Item',array("url"=>array("controller"=>"items"))); ?>
        <h4>New Item</h4>
        <input type="hidden" value="<?php echo rand(1000, 9999)?>" name="random" style="height:25px;" />
        <?php echo $this->Form->input('name',array("type"=>"text")); ?>
        <?php echo $this->Form->input('brands',array("url"=>array('controller'=>'items'))); ?>
        <?php echo $this->Form->input('colors',array("url"=>array('controller'=>'items'))); ?>
        <?php echo $this->Form->input('conditions',array("url"=>array('controller'=>'items'))); ?>
        <?php echo $this->Form->input('sizes',array("url"=>array('controller'=>'items'))); ?>
        <?php echo $this->Form->input('categories',array("url"=>array('controller'=>'items'))); ?>


        <!--<?php echo $this->Form->input('itemStatuses',array("url"=>array('controller'=>'items'))); ?>-->

        <?php echo $this->Form->input('description'); ?>

     </div>

    <div id="inforight">

     <?php $onlines = array('Yes' => 'Yes', 'No' => 'No'); ?>
        <?php echo $this->Form->input('Item.online', array('options' => $onlines, 'default' => 'No')); ?>

       <?php $locations = array_combine( array('Backstorage', 'Shelf'),array('Backstorage', 'On Display')); ?>
        <?php echo $this->Form->input('Item.location', array('options' => $locations, 'default' => 'Backstorage')); ?>
        <?php echo $this->Form->input('Item.original_price'); ?>
        <?php $is_discounted = array('Yes' => 'Yes', 'No' => 'No'); ?>
        <?php echo $this->Form->input('Item.is_discounted', array('options' => $is_discounted, 'default' => 'No'));?>
       <!-- <?php echo $this->Form->input('image_id'); ?> -->

        <div class="addPhotosFields" id="addPhotosFields">
        <?php
         echo $this->Form->input('Image.0.name', array('label' => false, 'div' => false, 'type' => 'file', 'class' => 'addPhotoButton'));
         echo $this->Form->input('Image.1.name', array('label' => false, 'div' => false, 'type' => 'file', 'class' => 'addPhotoButton'));
         echo $this->Form->input('Image.2.name', array('label' => false, 'div' => false, 'type' => 'file', 'class' => 'addPhotoButton'));
         echo "<input type='button' id='more-fields' onclick='addFields();' value='Add more images' />";
          ?>
        <button type="button" class="close">Close</button><br>
        <?php echo $this->Form->end(__('Submit')); ?>
        </div>
    </div>





<script type="text/javascript">
$(document).ready(function(){
	 $('#ItemAddForm').ajaxForm({
		 complete: function (xhr) {
			 var data = JSON.parse(xhr.responseText);
			 alert(data.message);
			 //Save successful, reload page
			 if(data.status){
				 $("#ItemId").empty();
				 $.each(data.itemlist,function(index,elem){
					 $("#ItemId").append("<option value="+elem.id+">"+elem.name+"</option>");
					 });
				}
			$('#mask, .popupInfoItem').fadeOut(400);
			$("#ItemAddForm #ItemName").val("");
		    return false;
		   }
		});

});
</script>
<!-- popup button for item ends -->







<! -- popup button for consigner -->
<?php echo $this->Html->script('jquery.form'); ?>
<div id="popup-box-consigner" class="popupInfo">


	<?php echo $this->Form->create('Consigner',array("url"=>array("controller"=>"consigners"))); ?>
	<h4>New consigner</h4>
	<input type="hidden" value="<?php echo rand(1000, 9999)?>" name="random" style="height:25px;" />
    <?php echo $this->Form->input('name',array("type"=>"text")); ?>
    <?php echo $this->Form->input('Email',array("type"=>"text")); ?>
    <?php echo $this->Form->input('Phone',array("type"=>"text")); ?>
    <?php echo $this->Form->input('Address',array("type"=>"text")); ?>
    <?php echo $this->Form->input('Note',array("type"=>"text")); ?>

	<button type="button" class="close">Close</button><br>
	<?php echo $this->Form->end(__('Submit')); ?>
</div>



<script type="text/javascript">
$(document).ready(function(){
	 $('#ConsignerAddForm').ajaxForm({
		 complete: function (xhr) {
			 var data = JSON.parse(xhr.responseText);
			 alert(data.message);
			 //Save successful, reload page
			 if(data.status){
				 $("#ConsignerId").empty();
				 $.each(data.consignerlist,function(index,elem){
					 $("#ConsignerId").append("<option value="+elem.id+">"+elem.name+"</option>");
					 });
				}
			$('#mask, .popupInfo').fadeOut(400);
			$("#ConsignerAddForm #ConsignerName").val("");
		    return false;
		   }
		});

});
</script>
<!-- popup button for consigner ends -->







<!-- popup button for consigner begins

<?php echo $this->Html->script('jquery.form'); ?>
<div id="popup-box-consigner" class="popupInfo">



	<?php echo $this->Form->create('Consigner',array("url"=>array("controller"=>"consigners"))); ?>
	<h4>New Consigner</h4>
    <input type="hidden" value="<?php echo rand(1000, 9999)?>" name="random" style="height:25px;" />
    <?php echo $this->Form->input('name',array("type"=>"text")); ?>
    <?php echo $this->Form->input('Email',array("type"=>"text")); ?>
    <?php echo $this->Form->input('Phone',array("type"=>"text")); ?>
    <?php echo $this->Form->input('Address',array("type"=>"text")); ?>
    <?php echo $this->Form->input('Note',array("type"=>"text")); ?>

    <button type="button" class="close">Close</button><br>
	<?php echo $this->Form->end(__('Submit')); ?>





<script type="text/javascript">
$(document).ready(function(){
	 $('#ConsignerAddForm').ajaxForm({
		 complete: function (xhr) {
			 var data = JSON.parse(xhr.responseText);
			 alert(data.message);
			 //Save successful, reload page
			 if(data.status){
				 $("#ConsignerId").empty();
				 $.each(data.consignerlist,function(index,elem){
					 $("#ConsignerId").append("<option value="+elem.id+">"+elem.name+"</option>");
					 });
				}
			$('#mask, .popupInfo').fadeOut(400);
			$("#ConsignerAddForm #ConsignerName").val("");
		    return false;
		   }
		});

});
</script>
popup button for consigner ends -->




















<script>
$(function() {
/*this dropdown list is from http://dropdown-check-list.googlecode.com/svn/trunk/doc/dropdownchecklist.html*/
$("#ddlIllness").dropdownchecklist({icon: {}});

//$("#s2").dropdownchecklist( {icon: {}, width: 150 } );

//the datepicker is part of jQueryUI http://jqueryui.com/
$("#dob").datepicker(
{
minDate: "-15y",
maxDate: "+1y",
dateFormat: "dd/mm/yy",
altFormat: "yy-mm-dd",
showOn: "button",
buttonImage: "<?php echo $this->webroot.IMAGES_URL; ?>/calendar.gif",
buttonImageOnly: true,
buttonText: 'Show',
changeMonth: true,
changeYear: true
});
});
</script>
